﻿using System;
namespace Producers.Etoimik.Xtee.Riik.Ee.Producer.Etoimik {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="KarrJareleparimine", Namespace="http://producers.etoimik.xtee.riik.ee/producer/etoimik", Target=typeof(KarrJareleparimine))]
    public class KarrJareleparimineSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IKarrJareleparimine clazz;
        
        public KarrJareleparimineSerializer(IKarrJareleparimine clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            if (clazz.Jareleparija!=null) {
                Writer.WriteStartElement("Jareleparija");
                global::Xtee.Core.SerializationMetadata metaJareleparija = this.GetMetaData(clazz.Jareleparija);
                Writer.WriteTypeAttribute(metaJareleparija.TypeQualifiedName.Namespace, metaJareleparija.TypeQualifiedName.Name);
                metaJareleparija.NewSerializer(clazz.Jareleparija).WriteXml(Writer);
                Writer.WriteEndElement();
            }
            if (clazz.ParinguID!=null) {
                Writer.WriteStartElement("ParinguID");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "int");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInt(((int)(clazz.ParinguID))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.OnValideeritud!=null) {
                Writer.WriteStartElement("OnValideeritud");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "boolean");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdBoolean(((bool)(clazz.OnValideeritud))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.FailiObjektID!=null) {
                Writer.WriteStartElement("FailiObjektID");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "long");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdLong(((long)(clazz.FailiObjektID))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.ParinguLiikKL!=null) {
                Writer.WriteStartElement("ParinguLiikKL");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "long");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdLong(((long)(clazz.ParinguLiikKL))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.ParinguEesmarkKL!=null) {
                Writer.WriteStartElement("ParinguEesmarkKL");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "long");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdLong(((long)(clazz.ParinguEesmarkKL))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Pohjendus!=null) {
                Writer.WriteStartElement("Pohjendus");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Pohjendus))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Infosysteem!=null) {
                Writer.WriteStartElement("Infosysteem");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Infosysteem))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.ValitudTeostamiseAeg!=null) {
                Writer.WriteStartElement("ValitudTeostamiseAeg");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "dateTime");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDateTime(((System.DateTime)(clazz.ValitudTeostamiseAeg))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.TeostamiseAeg!=null) {
                Writer.WriteStartElement("TeostamiseAeg");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "dateTime");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDateTime(((System.DateTime)(clazz.TeostamiseAeg))).ToString());
                Writer.WriteEndElement();
            }
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="Jareleparija") {
                if ((Reader.IsElementNil() == false)) {
                    global::Xtee.Core.SerializationMetadata metaJareleparija = this.GetMetaData<global::Producers.Etoimik.Xtee.Riik.Ee.Producer.Etoimik.IIsik>(Reader, "Isik", "http://producers.etoimik.xtee.riik.ee/producer/etoimik");
                    clazz.Jareleparija = metaJareleparija.NewEntity<global::Producers.Etoimik.Xtee.Riik.Ee.Producer.Etoimik.IIsik>();
                    if ((Reader.IsEmptyElement == false)) {
                        Reader.ReadStartElement("Jareleparija");
                        metaJareleparija.NewSerializer(clazz.Jareleparija).ReadXml(Reader);
                        Reader.ReadEndElement();
                    }
                    else {
                        Reader.Skip();
                    }
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="ParinguID") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.ParinguID = new global::Xtee.Core.Schema.XsdInt(Reader.ReadElementString("ParinguID")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="OnValideeritud") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.OnValideeritud = new global::Xtee.Core.Schema.XsdBoolean(Reader.ReadElementString("OnValideeritud")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="FailiObjektID") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.FailiObjektID = new global::Xtee.Core.Schema.XsdLong(Reader.ReadElementString("FailiObjektID")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="ParinguLiikKL") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.ParinguLiikKL = new global::Xtee.Core.Schema.XsdLong(Reader.ReadElementString("ParinguLiikKL")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="ParinguEesmarkKL") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.ParinguEesmarkKL = new global::Xtee.Core.Schema.XsdLong(Reader.ReadElementString("ParinguEesmarkKL")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="Pohjendus") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.Pohjendus = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Pohjendus")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="Infosysteem") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.Infosysteem = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Infosysteem")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="ValitudTeostamiseAeg") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.ValitudTeostamiseAeg = new global::Xtee.Core.Schema.XsdDateTime(Reader.ReadElementString("ValitudTeostamiseAeg")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="TeostamiseAeg") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.TeostamiseAeg = new global::Xtee.Core.Schema.XsdDateTime(Reader.ReadElementString("TeostamiseAeg")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
        }
    }
}
